package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

/**
 * @author Xiahu
 * @create 2023/8/3 0003
 */
public class PrestoJDBCTool {

    public Connection connection;
    public Statement statement;

    public void connect() throws SQLException, ClassNotFoundException {
        String url = "jdbc:presto://10.10.9.63:7670";
        Properties properties = new Properties();
        properties.setProperty("user", "presto");
        properties.setProperty("password", "");

        Class.forName("com.facebook.presto.jdbc.PrestoDriver");
        connection = DriverManager.getConnection(url, properties);
        statement = connection.createStatement();
    }

    public void close() throws SQLException {
        if (statement != null) {
            statement.close();
        }

        if (connection != null) {
            connection.close();
        }
    }
}
